package com.yunshipei.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.yunshipei.enterplorer.R;
import com.yunshipei.model.NotifyInfo;

import java.util.List;

/**
 * Created by cike on 15-11-26.
 */
public class DestroyNotifiAdapter extends BaseAdapter {
    private ListView mListView = null;
    private List<NotifyInfo> list = null;
    private Context context = null;

    public DestroyNotifiAdapter(Context context, List<NotifyInfo> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        if (list != null) {
            return list.size();
        } else {
            return 0;
        }
    }

    @Override
    public Object getItem(int position) {
        if (list != null) {
            return this.list.get(position);
        }
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    public void updateListView(List<NotifyInfo> list1) {
        this.list = list1;
        this.notifyDataSetChanged();
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (mListView == null) {
            mListView = (ListView) parent;
        }
        HolderView holderView = null;
        if (convertView == null) {
            holderView = new HolderView();
            convertView = LayoutInflater.from(context).inflate(R.layout.destory_notifi_list, parent, false);
            holderView.statusImg = (ImageView) convertView.findViewById(R.id.notfi_status);
            holderView.content = (TextView) convertView.findViewById(R.id.content_view);
            holderView.statusContent = (TextView) convertView.findViewById(R.id.status_content);
            convertView.setTag(holderView);
        } else {
            holderView = (HolderView) convertView.getTag();
        }
        holderView.content.setText(list.get(position).getSpeechRecognition().getContent());
        holderView.statusContent.setText("已完成");
        return convertView;
    }


    class HolderView {
        ImageView statusImg;
        TextView content;
        TextView statusContent;

        public ImageView getStatusImg() {
            return statusImg;
        }

        public void setStatusImg(ImageView statusImg) {
            this.statusImg = statusImg;
        }

        public TextView getContent() {
            return content;
        }

        public void setContent(TextView content) {
            this.content = content;
        }

        public TextView getStatusContent() {
            return statusContent;
        }

        public void setStatusContent(TextView statusContent) {
            this.statusContent = statusContent;
        }
    }
}
